//
//  ViewController.m
//  28-UIViewAnimation2
//
//  Created by dllo on 16/8/22.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "UIView+Frame.h"
@interface ViewController ()
@property (nonatomic,strong) UIView *myView;
@property (nonatomic,strong) UIButton *button;
@property (nonatomic,strong) UIButton *button1;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    _button = [UIButton buttonWithType:UIButtonTypeCustom];
    _button.frame = CGRectMake(100, 100, 200, 200);
    _button.backgroundColor = [UIColor blackColor];
    [_button addTarget:self action:@selector(buttonClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_button];
    
    _button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    _button1.backgroundColor = [UIColor blueColor];
    _button1.frame = CGRectMake(100, 300, 200, 200);
    
}

- (void)buttonClicked
{
//    动画效果
    [UIView transitionWithView:self.view duration:5 options:    UIViewAnimationOptionRepeat
 animations:^{
//        _myView.fll_height = 200;
    } completion:^(BOOL finished) {
//        动画可以嵌套使用
        [UIView animateWithDuration:0.5 animations:^{
            _button.fll_height = 40;
        }];
//        _button.fll_height = 100;
    }];
    
    
//    [UIView transitionFromView:_button toView:_button1 duration:5 options:UIViewAnimationOptionRepeat | UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) {
////        _myView.fll_height = 60;
////        _myView.fll_width = 300;
////        _button.fll_width = 300;
////        _button.fll_height = 50;
//    }];
    
    
    
    
}

- (void)viewDidAppear:(BOOL)animated
{
    _myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
    _myView.backgroundColor = [UIColor greenColor];
    [self.view addSubview:_myView];
    
    
    
    //    参数1
    //    参数2
    //    参数3 0.0~1.0,数值小，阻力小
    //    参数4 速度
    //    参数5 选项
    [UIView animateWithDuration:5 delay:0.5f usingSpringWithDamping:1.0f initialSpringVelocity:0.1f options:UIViewAnimationOptionCurveLinear animations:^{
        _myView.fll_width = 50;
        _myView.fll_height = 300;
        _myView.backgroundColor = [UIColor yellowColor];
    } completion:^(BOOL finished) {
        
    }];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
